/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

/* Layout */
.header {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav__logo {
    color: #2563eb;
    font-size: 1.5rem;
    font-weight: 600;
}

.nav__menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav__link {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.nav__link:hover {
    background-color: #f1f5f9;
    color: #334155;
}

.nav__link.active {
    background-color: #2563eb;
    color: white;
}

.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: calc(100vh - 200px);
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section h2 {
    color: #1e293b;
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 600;
}

.footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 1rem;
    text-align: center;
    color: #64748b;
    margin-top: 3rem;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e2e8f0;
}

.card h3 {
    color: #1e293b;
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Grid Layouts */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Status and Time Displays */
.status-display {
    text-align: center;
    padding: 1rem;
}

.time-display {
    text-align: center;
    padding: 1rem;
}

.time-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2563eb;
    display: block;
}

.time-unit {
    color: #64748b;
    font-size: 1rem;
}

.progress-display {
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 0.75rem;
    background-color: #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background-color: #10b981;
    transition: width 0.3s ease;
}

.progress-text {
    color: #64748b;
    font-weight: 500;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #64748b;
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: #374151;
}

.form-input,
.form-select,
.form-textarea {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    resize: vertical;
    font-family: inherit;
}

/* Enhanced time input styles */
.time-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.time-slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background-color: #f8fafc;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.time-slider {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.time-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.time-preview {
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    font-size: 1.125rem;
    color: #1e293b;
    background-color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.quick-time-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn-quick-time {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-quick-time:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.btn-quick-time.active {
    background-color: #2563eb;
    color: white;
    border-color: #2563eb;
}

.sleep-duration-display {
    margin: 1.5rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f8fafc, #e0e7ff);
    border-radius: 0.5rem;
    border: 1px solid #c7d2fe;
    text-align: center;
}

.sleep-duration-display.good-duration {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: #86efac;
}

.sleep-duration-display.poor-duration {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #fca5a5;
}

.sleep-duration-display.conflict-duration {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border-color: #f87171;
    animation: pulse-warning 1.5s infinite;
}

.time-conflict-warning {
    margin: 0.5rem 0;
    padding: 0.5rem;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.375rem;
    color: #dc2626;
    font-size: 0.875rem;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

@keyframes pulse-warning {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
    }
}

.sleep-duration-display label {
    display: block;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.duration-preview {
    display: flex;
    justify-content: center;
    align-items: center;
}

.duration-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2563eb;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

.form-actions .btn {
    min-width: 120px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .time-slider-container {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem;
    }

    .quick-time-buttons {
        gap: 0.25rem;
    }

    .btn-quick-time {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions .btn {
        width: 100%;
    }

    .sleep-duration-display {
        margin: 1rem 0;
        padding: 0.75rem;
    }

    .duration-value {
        font-size: 1.25rem;
    }
}

/* Lists */
.history-list,
.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar,
.activity-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track,
.activity-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb,
.activity-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover,
.activity-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Sleep History Items */
.sleep-history-item {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.sleep-history-item:last-child {
    border-bottom: none;
}

.sleep-date {
    font-weight: 600;
    color: #1e293b;
    min-width: 80px;
}

.sleep-times {
    flex: 1;
    margin: 0 1rem;
}

.sleep-times > div {
    margin-bottom: 0.25rem;
    color: #374151;
}

.sleep-duration {
    font-weight: 500;
    color: #64748b;
    font-size: 0.875rem;
}

/* Clickable time elements */
.clickable-time {
    color: #2563eb;
    cursor: pointer;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
    text-decoration: underline dotted;
}

.clickable-time:hover {
    background-color: #dbeafe;
    color: #1d4ed8;
    text-decoration: underline solid;
}

/* Activity Items */
.activity-item {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-info {
    flex: 1;
}

.activity-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.activity-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.category-work {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.category-personal {
    background-color: #fce7f3;
    color: #a21caf;
}

.category-leisure {
    background-color: #dcfce7;
    color: #15803d;
}

.category-exercise {
    background-color: #fed7aa;
    color: #c2410c;
}

.category-learning {
    background-color: #fef3c7;
    color: #b45309;
}

.category-other {
    background-color: #f3f4f6;
    color: #6b7280;
}

.activity-duration {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.activity-description {
    font-size: 0.875rem;
    color: #64748b;
    font-style: italic;
}

/* Charts */
.chart-container {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    text-align: center;
}

/* Goals */
.goals-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.goal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: #f8fafc;
    border-radius: 0.5rem;
}

.mini-progress {
    width: 200px;
    height: 0.5rem;
    background-color: #e2e8f0;
    border-radius: 0.25rem;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background-color: #10b981;
    transition: width 0.3s ease;
}

/* Export Options */
.export-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-muted {
    color: #64748b;
}

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* Responsive Design */
@media (max-width: 768px) {
    .nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav__menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .main {
        padding: 1rem;
    }

    .dashboard-grid,
    .statistics-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .activity-item {
        flex-direction: column;
        gap: 1rem;
    }

    .goal-item {
        flex-direction: column;
        gap: 0.5rem;
        align-items: start;
    }

    .mini-progress {
        width: 100%;
    }

    .export-options {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
    line-height: 1;
}

.modal-close:hover {
    background-color: #f1f5f9;
    color: #1e293b;
}

.modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Inline Time Editor */
.inline-time-editor {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quick-adjustment-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.inline-edit-status {
    padding: 0.5rem;
    border-radius: 0.375rem;
    text-align: center;
    font-size: 0.875rem;
    min-height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inline-edit-status.error {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section.active {
    animation: fadeIn 0.3s ease;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #64748b;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}